(function($) {
	$(document).ready(function() {
		setPage();
		
		// Setup drop down menu
		$('.dropdown-toggle').dropdown();

		// Fix input element click problem
		$('.dropdown input, .dropdown label').click(function(e) {
			e.stopPropagation();
		});

		// carregar imagens
		var $this, $path = $('#data-path').html();
		$('img').each(function() {
			$this = $(this);
			$this.data = $this.attr('data-src');
			if ($this.data)
				$this.attr('src', $path + 'img/' + $this.data);
		});
	});
})(jQuery);

/* FUNÇÕES PARA MODIFICAR LINK ATIVO ACIMA */
function extractPageName(hrefString){
	var arr = hrefString.split('/');
	return  (arr.length < 2) ? hrefString : arr[arr.length-2].toLowerCase() + arr[arr.length-1].toLowerCase();
}
function setActiveMenu(arr, crtPage){
	for (var i=0; i < arr.length; i++){
		if(extractPageName(arr[i].href) == crtPage){
			if (arr[i].parentNode.tagName != "DIV"){
				arr[i].className = "active";
				arr[i].parentNode.className = "active";
			}
		}
	}
}
function setPage(){
	hrefString = document.location.href ? document.location.href : document.location;
	if(document.getElementById("nav")!=null){setActiveMenu(document.getElementById("nav").getElementsByTagName("a"), extractPageName(hrefString));}
}